package com.xf.thread;

public class RunnableTest {
    public static void main(String[] args) {
        // 1 通过实现Runnable接口创建线程
        MyRunnable myRunnable = new MyRunnable();
        Thread thread = new Thread(myRunnable);
        thread.start();

        // 2: 通过匿名内部类创建线程
        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("通过匿名内部类创建线程");
            }
        });
        thread1.start();

    }
}

class MyRunnable implements Runnable {
    @Override
    public void run() {
        System.out.println("实现Runnable接口实现多线程");
    }
}
